<!DOCTYPE html>
<html>
<head>
    <meta charset="x-UTF-16LE-BOM">
    <title>在表格中输出圆的周长和面积</title>
</head>
<body>
<div class="main">
    <form method="post" action="案例.php">
        <label>
            <b>请输入圆的半径：</b>
            <input type="text" name="r">
            <input type="submit" value="计算">
        </label>
</div>
</form>
</body>
</html>
<?php
error_reporting(0);
if ($_POST["r"]) {
    define("pi", 3.14);
    $r = $_POST["r"];
    $c = 2 * pi * $r;
    $s = pi * $r * $r;
    //第一个
    echo "<br><hr>";
    echo "<table  border='10';>";
    echo "<tr><th>计算圆的周长和面积</th></tr>";
    echo "<tr><td>圆的半径:$r</td></tr>";
    echo "<tr><td>圆的周长:$c</td></tr>";
    echo "<tr><td>圆的面积:$s</td></tr>";
    echo "</table>";
    echo "<br><hr>";
    //第二个
    echo "<table border='10';>";
    echo "<tr><th>数据类型</th></tr>";
    echo "<tr><td>半径:";
    echo var_dump($r);
    echo "</td></tr>";
    echo "<tr><td>周长:";
    echo var_dump($c);
    echo "</td></tr>";
    echo "<tr><td>面积:";
    echo var_dump($s);
    echo "</td></tr>";
    echo "</table>";
    echo "<br><hr>";
    //第三个
    echo "<table  border='10';>";
    echo "<tr><th>检测数据类型</th></tr>";
    echo "<tr><td>半径是否为整形:";
    echo var_dump((bool)is_int($r));
    echo "</td></tr>";
    echo "<tr><td>周长是否由数字组成:";
    echo var_dump((bool)is_numeric($c));
    echo "</td></tr>";
    echo "<tr><td>面积是否为字符串型:";
    echo var_dump((bool)is_string($s));
    echo "</td></tr>";
    echo "</table>";
    echo "<br><hr>";
    //第四个
    echo "<table  border='10';>";
    echo "<tr><th>转换数据类型</th></tr>";
    echo "<tr><td>将半径转换为整形:";
    echo (int)$r;
    echo "</td></tr>";
    echo "<tr><td>将周长转换为字符串型:";
    echo (string)$c;
    echo "</td></tr>";
    echo "<tr><td>将面积转换为整形:";
    echo (int)$s;
    echo "</td></tr>";
    echo "</table>";
    echo "<br><hr>";
    //第五个
    echo "<table  border='10';>";
    echo "<tr><th>运算符的应用</th></tr>";
    echo "<tr><td>面积比周长大:";
    echo var_dump($s > $c);
    echo "</td></tr>";
    echo "<tr><td>只要面积大于200以及周长小于100就是个完美的圆，请问您做的圆完美吗:";
    echo var_dump($s > 200 && $c < 100);
    echo "</td></tr>";
    echo "<tr><td>只要面积大于100或者周长小于50就及格，请问您做的及格吗:";
    echo $s > 100 || $c < 50 ? "及格" : "不及格";
    echo "</td></tr>";
    echo "<tr><td>如果不完美，将面积自增，每加1:  ";
//    三元
    echo $s > 200 && $c < 100 ? $s : ++$s;
//    if
//    if ($s > 200 && $c < 100) {
//        echo $s;
//    } else {
//        echo ++$s;
//    }
//

    echo "</td></tr>";
    echo "<tr><td>如果不完美，将周长自减，每加1: ";
    echo $s > 200 && $c < 100 ? $s : --$s;
//    if
//    if ($s > 200 && $c < 100) {
//        echo $s;
//    } else {
//        echo --$c;
//    }
    echo "</td></tr>";
    echo "</table>";
}
?>